Skip to content

Bugfix: Add support for pull option in podman#23032

Open
tim-werner wants to merge 13 commits intopantsbuild:mainfrom
tim-werner:main
Open

Bugfix: Add support for pull option in podman#23032
tim-werner wants to merge 13 commits intopantsbuild:mainfrom
tim-werner:main

Conversation

@tim-werner
Copy link
Copy Markdown
Contributor

This pull request will fix issue: #21450

It is now possible to use booleans for Docker container for the docker_image option --pull AND missing, never, always or newer. Using one of the strings and the Docker backend will result in an error. In the podman case, booleans are converted to podman policy strings - False = missing and True= always - to ensure backwards compatibility. I have added a deprecation warning in those cases.

Disclaimer: AI was used for support, but all code was reviewed, adapted, and tested by a human.

@tim-werner
Copy link
Copy Markdown
Contributor Author

ahh I have been afraid that this will happen. I need probably a new target type that except both but not sure if it will crash somewhere else than...

@sureshjoshi
Copy link
Copy Markdown
Member

sureshjoshi commented Jan 24, 2026

This is one of those annoying problems. We have Podman support, which is "supposed" to be a mostly drop-in replacement for Docker, but in practice it isn't - and our implementation is overtly Docker-centric too.

Can't wait to try on Apple Containers, on top of everything else.

@sureshjoshi sureshjoshi self-requested a review January 24, 2026 16:04
@ndellosa95
Copy link
Copy Markdown
Contributor

I can open a draft PR to show you my approach but I have been working on code to support building images directly with Buildkit sans Docker. To implement this, I added the concept of "engines" for the Docker backend, which lets you control which tool you use for builds and runs, but can definitely add push and pull as well. It uses separate SystemBinary classes for each binary. Currently I have a mixin for docker and podman functionality, since they're the same in 99% of cases but it would be trivial to add separate pull functionality for podman.

This should let us easily add new OCI image platforms (like Apple containers) as well.

@tim-werner
Copy link
Copy Markdown
Contributor Author

Hi @ndellosa95 ,
would be great if you could open a draft PR with your suggestions. My pull request does not realy fix the issue in a generic way and it will only work for the pull flag.

@cburroughs
Copy link
Copy Markdown
Contributor

Thanks for the contribution. We've just branched for 2.31.x, so merging this pull request now will come out in 2.32.x, please move the release notes updates to docs/notes/2.32.x.md if that's appropriate.

@tim-werner
Copy link
Copy Markdown
Contributor Author

@sureshjoshi finally had time to work again on it

@sureshjoshi
Copy link
Copy Markdown
Member

Alright, not working on my machine - but... I've also been doing some craziness. I'll try to dig through and see what comes up

# Boolean value
if is_podman:
# Convert boolean to Podman policy string
warnings.warn(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the reason to use warnings?

return value_or_default


class StringOrBoolField(Field):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I don’t particularly like this target. Is it strictly here to maintain backwards compatibility on the docker_image target?

)


def create_test_context(rule_runner: RuleRunner, pull_value=None):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The writing of this test feels a bit too clever, with all the conditionals. It looks less clean to maintain then maybe a single “file” template that can accept a value maybe.

I had to read it a couple times to actually understand it.

@sureshjoshi
Copy link
Copy Markdown
Member

Thanks for the PR, but I feel like we’ve done a disservice to Podman by making it this weird, opt-in cousin to Docker - and that means we have to hack and patch our way to some more reasonable support.

If it was all internals, that would be one thing as we could clean it up, but this is API level tweaks and they make me a bit nervous due to them being semi-locked in for a while.

Just thinking out loud, but do we need a separate podman_image? That seems silly to need to surface to users (in fact, since we’re using OCI containers, it could even be more generic than “docker”).

In other targets, we allow customization via extra_args or some variants. We have extra build args - is that a place where we could put the pull command until we have better container support?

)
docker_build_option = "--pull"

def options(self, value_formatter, global_build_hosts_options=None, **kwargs):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function doesn’t feel like idiomatic Pants, but I don’t know exactly why.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants